//
//  MonitorItemTableViewCell.m
//  CityFire
//
//  Created by  androidlongs on 2017/11/6.
//  Copyright © 2017年 刘养柱. All rights reserved.
//

#import "MonitorItemTableViewCell.h"


@interface  MonitorItemTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *deviceNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *deviceNoLabel;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
@property (weak, nonatomic) IBOutlet UILabel *sourceLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *deviceTypeLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UIView *moreResultView;
@property (weak, nonatomic) IBOutlet UIButton *selectMoreButton;
@property (weak, nonatomic) IBOutlet UIView *contentView;

@end

@implementation MonitorItemTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setMonitorModel:(MonitorModel *)monitorModel
{
    self.deviceNameLabel.text = monitorModel.deviceName;
    self.deviceNoLabel.text = [NSString stringWithFormat:@"设备编号:%ld", monitorModel.deviceCode];
    //    [UIColor colorWithRed: / 255.0 green:/ 255.0 blue: / 255.0 alpha:1.0f]
    self.statusLabel.text = monitorModel.misinformation;
    self.statusLabel.textColor = [monitorModel.misinformation containsString:@"否"] ? [UIColor orangeColor] : [UIColor greenColor];
    self.sourceLabel.text = monitorModel.record1;
    self.contentLabel.text = monitorModel.record3;
    self.deviceTypeLabel.text =[NSString stringWithFormat:@"类型：%@",monitorModel.record2] ;
    NSString *str = [NSString stringWithFormat:@"%ld",monitorModel.timeHistory];
    NSString *breaktime = [NSString timeWithTimeIntervalString:str];
    self.timeLabel.text = breaktime;
    
    
    [self.selectMoreButton setSelected:monitorModel.isSelect];
    
    
    
    if (self.isShowMoreResult) {
        self.moreResultView.hidden=NO;
        CGRect frame = self.contentView.frame;
        frame.origin.x=0;
        
        self.contentView.frame=frame;
    } else {
        self.moreResultView.hidden=YES;
        CGRect frame = self.contentView.frame;
        frame.origin.x=20;
        //self.contentView.frame=frame;
       
    }
}
- (IBAction)selectButtonClick:(id)sender {
    
    if(self.selectMoreButton.isSelected){
        [self.selectMoreButton setSelected:NO];
        self.monitorModel.isSelect=NO;
        self.canCalclelBackBlock(self.index);
    }else{
        [self.selectMoreButton setSelected:YES];
        self.selectCallBackBlock(self.index);
        self.monitorModel.isSelect=YES;
    }
}



@end
